import { getSearchRecord, removeSearchRecord, setSearchRecord } from '@/utils/storage'

export default {
  state () {
    return {
      record: getSearchRecord()
    }
  },
  getters: {},
  mutations: {
    addSearchRecord (state, record) {
      state.record.unshift(record)
      state.record = Array.from(new Set(state.record))
      console.log(state.record)
      setSearchRecord(state.record)
    },
    clearRecord (state) {
      removeSearchRecord()
      state.record = []
    }
  },
  actions: {},
  namespaced: true
}
